package com.dcw.lixb.designmode.chain_of_responsibility;

/**
 * @author lixiaobin
 * @date 2020-07-23 16:12:23
 * @desc 描述信息
 */
public abstract class AbstractLogger {
    public static final int INFO = 1;
    public static final int DEBUG = 2;
    public static final int WARNING = 3;
    public static final int ERROR = 4;

    protected int level;

    public void setLevel(int level) {
        this.level = level;
    }

    public void setNextLogger(AbstractLogger nextLogger) {
        this.nextLogger = nextLogger;
    }

    protected AbstractLogger nextLogger;

    public void logMessage(int level, String msg) {
        if (level <= this.level) {
            writeMessage(msg);
        }else {
            if (null != nextLogger) {
                nextLogger.logMessage(level,msg);
            }
        }
    }

    protected abstract void writeMessage(String msg);
}
